<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>

    <h1 id="h1"></h1>
    

    <script>

        var oH1 = document.getElementById("h1");
    
        var obj = {
            _title: "一个标题",
            get title() {
                console.log("有人获取title")
                return this._title;
            },
            set title(val) {
                console.log("有人设置title")
                this._title = val;
                oH1.innerHTML = val;
            }
        }

        oH1.innerText = obj.title;

    </script>

</body>
</html>